var t = require("../../../../@babel/runtime/helpers/typeof"), e = getApp();

Page({
    data: {
        language: "",
        is_first_content: !1,
        is_second_content: !1,
        mailLanguage: "",
        mailFullReturnTitle: "",
        mailFullReturnName: "",
        activeName: "first",
        first_content: [],
        second_content: [],
        alreadyReturn: 0,
        each_return_rate: 0,
        order_return_rate: 0,
        returnAmountTotal: 0,
        notReturn: 0,
        fullReturnName: "",
        isShow: !1,
        return_list_name: "",
        page: 1
    },
    onLoad: function(t) {
        this.checkrouter(), this.initMailLanguage(), this.getData();
    },
    checkrouter: function() {
        try {
            var e = function() {
                for (var t = wx.getStorageSync("yz_basic_info"), e = t.popularize_page.mini.vue_route, a = 0; a < e.length; a++) if ("full_return_center" == e[a]) return console.log(t.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: t.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === t(e)) return e.v;
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (console.log(this.data.current_page, this.data.last_page), !(this.data.current_page >= this.data.last_page)) {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    initMailLanguage: function() {
        var t, a = this, n = e.getNetAddresss("setting.get-lang-setting");
        e._getNetWork({
            url: n,
            success: function(n) {
                var r = n.data;
                if (1 === r.result) {
                    t = r.data;
                    var i = e.setMailLanguage("消费满额赠送", t.full_return.full_return), o = e.setMailLanguage("赠送", t.full_return.return_name), l = e.setMailLanguage("满额返现记录", t.full_return.full_return_log);
                    a.setData({
                        mailLanguage: t,
                        mailFullReturnTitle: i,
                        mailFullReturnName: o,
                        mailFullReturnLog: l
                    }), wx.setNavigationBarTitle({
                        title: o || ""
                    });
                } else wx.showToast({
                    title: r.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var t = this, a = e.getNetAddresss("plugin.full-return.frontend.list.index");
        e._getNetWork({
            url: a,
            data: {
                page: this.data.page
            },
            success: function(e) {
                var a = e.data;
                if (1 === a.result) {
                    var n = !1;
                    n = "0" != a.data.is_show_return_list, t.setData({
                        alreadyReturn: a.data.finish,
                        returnAmountTotal: a.data.total,
                        notReturn: a.data.surplus,
                        first_content: a.data.list.data,
                        fullReturnName: a.data.full_return_name,
                        isShow: n,
                        return_list_name: a.data.return_list_name,
                        current_page: a.data.list.current_page,
                        last_page: a.data.list.last_page
                    });
                } else wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var t = this, a = e.getNetAddresss("plugin.full-return.frontend.list.index");
        e._getNetWork({
            url: a,
            data: {
                page: t.data.page
            },
            success: function(e) {
                var a = e.data;
                if (1 === a.result) {
                    var n = a.data.list.data;
                    t.setData({
                        first_content: t.data.first_content.concat(n),
                        current_page: a.data.list.current_page,
                        last_page: a.data.list.last_page
                    });
                } else wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    toReturnInfo: function(t) {
        var e = t.currentTarget.dataset.id || t.target.dataset.id;
        wx.navigateTo({
            url: "/packageB/member/income/full_return_list_info/full_return_list_info?id=" + e
        });
    },
    getReturnListInfo: function() {
        var t = this, a = e.getNetAddresss("plugin.full-return.frontend.detail.index");
        e._getNetWork({
            url: a,
            success: function(e) {
                var a = e.data;
                1 === a.result ? t.setData({
                    second_content: a.data
                }) : wx.showToast({
                    title: a.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});